package org.veloxbot.api;

import org.veloxbot.api.internals.Context;
import org.veloxbot.api.internals.PaintComposite;

import org.veloxbot.api.internals.concurrent.LoopTask;

import org.veloxbot.api.listeners.PaintListener;

import java.awt.Graphics;

/**
 * @author Velox
 */
public abstract class ActiveScript extends LoopTask implements PaintListener {

	private final Manifest manifest;

	public ActiveScript() {
		this.manifest = getClass().getAnnotation(Manifest.class);
		PaintComposite.submit(this);
	}

	/**
	 * Gets the script's manifest.
	 *
	 * @return The manifest of the script.
	 */
	public Manifest getManifest() {
		return manifest;
	}

	/**
	 * Stops the script.
	 */
	@Override
	public final void terminate() {
		super.terminate();
		Context.script = null;
		PaintComposite.revoke(this);
	}

	/**
	 * Draws to the given parameter.
	 *
	 * @param g The graphics to draw to.
	 */
	@Override
	public void onRepaint(final Graphics g) {
	}
}
